package com.tianzeculture.stagebao.activity.business;

import android.app.Activity;
import android.content.Intent;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tianzeculture.stagebao.R;
import com.tianzeculture.stagebao.bean.NoticeList;

import java.util.List;

import static com.tianzeculture.stagebao.activity.business.BusinessHomepagerActivity.ADAPTER_CODE;

/**
 * Created by Administrator on 2018/8/30.
 */

public class BusinessHomeAdapter extends BaseQuickAdapter<NoticeList, BaseViewHolder> {

    Activity activity;

    public BusinessHomeAdapter(@LayoutRes int layoutResId, @Nullable List<NoticeList> data) {
        super(layoutResId, data);
    }

    public BusinessHomeAdapter(@LayoutRes int layoutResId, @Nullable List<NoticeList> data, Activity activity) {
        super(layoutResId, data);
        this.activity = activity;
    }

    @Override
    protected void convert(BaseViewHolder helper, final NoticeList item) {
        LinearLayout linearLayout = helper.getView(R.id.linearLayout);
        helper.setText(R.id.tvJobTitle, item.getTitle());
        helper.setText(R.id.tvDingwei, item.getAddress());
        helper.setText(R.id.tvTime, item.getStarttime().substring(0, 10) + "~" + item.getEndtime().substring(0, 10));
        helper.setText(R.id.tvPerson, "人数:" + item.getPeople() + "人");
//        helper.setText(R.id.tvSex, item.getSex().equals("1") ? "男" : "女");
        TextView tvSex = helper.getView(R.id.tvSex);
        switch (item.getSex()) {
            case "1":
                tvSex.setText("男");
                break;
            case "0":
                tvSex.setText("女");
                break;
            default:
                tvSex.setText("不限");
                break;
        }
        helper.setText(R.id.tvHeight, "身高:" + item.getHeight());
        helper.setText(R.id.tvEntered, "已报名 " + item.getCntjob() + " 人");
        helper.setText(R.id.tvPrice, "¥" + item.getUnitPrice() + item.getPriceType());
        linearLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                activity.startActivityForResult(new Intent(activity, RecruitDetailActivity.class).putExtra("recruitDetail", item), ADAPTER_CODE);
            }
        });
    }
}
